<?php
include_once dirname(__FILE__) . "/../config/functions.php";
include_once dirname(__FILE__) . "/header.php";
?>


<div id="page-wrapper">

    <div class="row">
        <div class="col-lg-12">
            <?php
            //get member data
            if (!isset($_GET['id']) || !$_GET['id']):
                ?>
                <div class="alert alert-danger">
                    Sponsor Ad Not Found.
                </div>
                <?php
            else:
                $edit = FALSE;
                if (isset($_POST) && $_POST) {
                    mysql_query("update `ads` set `url` = '" . $_POST['url'] . "',`textAd` = '" . $_POST['textAd'] . "' WHERE id='" . $_GET['id'] . "' ");
                    $edit = TRUE;
                }

                $sponsor = mysql_query("select * from ads where id = " . $_GET['id']);
                $row = mysql_fetch_assoc($sponsor);
                if ($row):
                    ?>
                    <h1>Edit Sponsor Ad</h1>
                    <div class="editMemeber">
                        <?php if ($edit): ?>
                            <div class="alert alert-success alert-dismissable">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                                Banner updated successfully.
                            </div>
                        <?php endif; ?>
                        <form class="form-horizontal" role="form" method="post">
                            <div class="form-group">
                                <label for="url" class="col-sm-2 control-label"> Website Url</label>
                                <div class="col-sm-10">
                                    <input type="text" value="<?php echo $row['url']; ?>" class="form-control" name="url" id="url">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="textAd" class="col-sm-2 control-label">Text Ad</label>
                                <div class="col-sm-10">
                                    <input type="text" value="<?php echo $row['textAd']; ?>" class="form-control" name="textAd" id="textAd">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <button type="submit" class="btn btn-primary">Update</button>
                                </div>
                            </div>
                        </form>
                    </div>
                <?php else: ?>
                    <div class="alert alert-danger">
                        Sponsor Ad Not Found.
                    </div>
                <?php endif; ?>
            <?php endif; ?>

        </div>
    </div><!-- /.row -->

</div><!-- /#page-wrapper -->

<?php include_once dirname(__FILE__) . "/footer.php"; ?>